package org.etherframework.tests.features.wiring
{
	import org.etherframework.common.wire.IMetaProcessor;
	import org.etherframework.common.wire.IWiring;
	import org.etherframework.core.IModule;
	import org.etherframework.tests.features.wiring.processors.Hello;
	import org.etherframework.tests.utils.TestUtility;
	import org.etherframework.wire.ProcessorFactory;
	import org.hamcrest.assertThat;
	import org.hamcrest.object.notNullValue;
	import org.hamcrest.object.nullValue;

	public class when_creating_processor
	{	
		private static var _testUtility:TestUtility = new TestUtility();
		private static var _module:IModule;
		private static var _w:IWiring;
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
			_module = _testUtility.createModule();
			_w = _module.wiring;
			
			_w.addProcessor(new ProcessorFactory(Hello));
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
			_testUtility.dispose();
		}
		
		[Test(order=1)]
		public function it_should_be_created():void
		{
			var processor:IMetaProcessor = _w.createProcessor(Hello.NAME);
			assertThat(processor, notNullValue());
		}
		
		[Test(order=2)]
		public function it_should_return_null_when_processor_does_not_exist():void
		{
			var processor:IMetaProcessor;
			
			processor = _w.createProcessor("NotExistent");
			assertThat(processor, nullValue());
			processor = _w.createProcessor("");
			assertThat(processor, nullValue());
		}
		
	}
}